From 66168acd47ed5567a72f742faf89d1aa20b73e07 Mon Sep 17 00:00:00 2001 From: Paul Woolcock Date: Thu, 21 Apr 2016 12:23:33 -0400 Subject: [PATCH] old commit adding some support for multi-install --- src/bin/install.rs | 10 +++++----- tests/install.rs | 40 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/src/bin/install.rs b/src/bin/install.rs index 8d532e6bc..7aaca4d48 100644 --- a/src/bin/install.rs +++ b/src/bin/install.rs @@ -22,7 +22,7 @@ pub struct Options { flag_frozen: bool, flag_locked: bool, - arg_crate: Option, + arg_crate: Vec, flag_vers: Option, flag_git: Option, @@ -37,7 +37,7 @@ pub const USAGE: &'static str = " Install a Rust binary Usage: - cargo install [options] [] + cargo install [options] [...] cargo install [options] --list Specifying what crate to install: @@ -139,20 +139,20 @@ pub fn execute(options: Options, config: &Config) -> CliResult { SourceId::for_git(&url, gitref) } else if let Some(path) = options.flag_path { SourceId::for_path(&config.cwd().join(path))? - } else if options.arg_crate == None { + } else if options.arg_crate.is_empty() { SourceId::for_path(&config.cwd())? } else { SourceId::crates_io(config)? }; - let krate = options.arg_crate.as_ref().map(|s| &s[..]); + let krates = options.arg_crate.iter().map(|s| &s[..]).collect::>(); let vers = options.flag_vers.as_ref().map(|s| &s[..]); let root = options.flag_root.as_ref().map(|s| &s[..]); if options.flag_list { ops::install_list(root, config)?; } else { - ops::install(root, krate, &source, vers, &compile_opts, options.flag_force)?; + ops::install(root, krates, &source, vers, &compile_opts, options.flag_force)?; } Ok(()) } diff --git a/tests/install.rs b/tests/install.rs index 22f9af060..7a61b716e 100644 --- a/tests/install.rs +++ b/tests/install.rs @@ -55,7 +55,45 @@ warning: be sure to add `[..]` to your PATH to be able to run the installed bina } #[test] -fn pick_max_version() { +test!(multiple_pkgs { + pkg("foo", "0.0.1"); + pkg("bar", "0.0.1"); + + assert_that(cargo_process("install").arg("foo").arg("bar"), + execs().with_status(0).with_stdout(&format!("\ +{updating} registry `[..]` +{downloading} foo v0.0.1 (registry file://[..]) +{compiling} foo v0.0.1 (registry file://[..]) +{installing} {home}[..]bin[..]foo[..] +{downloading} bar v0.0.1 (registry file://[..]) +{compiling} bar v0.0.1 (registry file://[..]) +{installing} {home}[..]bin[..]bar[..] +", + updating = UPDATING, + downloading = DOWNLOADING, + compiling = COMPILING, + installing = INSTALLING, + home = cargo_home().display()))); + assert_that(cargo_home(), has_installed_exe("foo")); + assert_that(cargo_home(), has_installed_exe("bar")); + + assert_that(cargo_process("uninstall").arg("foo"), + execs().with_status(0).with_stdout(&format!("\ +{removing} {home}[..]bin[..]foo[..] +", + removing = REMOVING, + home = cargo_home().display()))); + assert_that(cargo_process("uninstall").arg("bar"), + execs().with_status(0).with_stdout(&format!("\ +{removing} {home}[..]bin[..]bar[..] +", + removing = REMOVING, + home = cargo_home().display()))); + assert_that(cargo_home(), is_not(has_installed_exe("foo"))); + assert_that(cargo_home(), is_not(has_installed_exe("bar"))); +}); + +test!(pick_max_version { pkg("foo", "0.0.1"); pkg("foo", "0.0.2"); -- 2.30.2